<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组任意位置的删除和添加</title>
</head>
<body>
    <script>
        // splice()：任意位置删除：splice(起始位置下标，删除个数)
        var arr = [1,2,3,4,5,6,7,8,9];
        var str = arr.splice(2,3);
        console.log(str);
        console.log(arr);

        // splice()：任意位置添加：splice(起始位置下标，删除个数，添加的元素)。可同时添加多个元素，添加时最少3个参数。
        var arr1 = [1,2,3,4,5,6,7,8,9];
        var str1 = arr1.splice(3,0,100,200,300);
        console.log(str1);
        console.log(arr1)
    </script>
</body>
</html>